# wwwinit.py
from sqlalchemy import create_engine
from models.user import Base as UserBase  # 导入用户模型的Base
from models.medical_history import Base as MedicalBase  # 导入病史模型的Base
from db import DATABASE_URL  # 确保数据库连接正确

# 连接数据库
engine = create_engine(DATABASE_URL)

# 先创建用户表（users），因为medical_history依赖它
UserBase.metadata.create_all(bind=engine)
# 再创建病史表（medical_history）
MedicalBase.metadata.create_all(bind=engine)

print("users表和medical_history表创建成功！")